package entities;

import java.io.Serializable;
import java.util.List;

import javax.persistence.*;

import ejb.dto.LocationDTO;


/**
 * The persistent class for the locations database table.
 * 
 */
@Entity
@Table(name="locations", uniqueConstraints=@UniqueConstraint(columnNames={"NAME", "NATION_ID"}))
@NamedQuery(name="Location.findAll", query="SELECT l FROM Location l")
public class Location implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;

	@Lob
	private String description;

	private String name;

	/**
	 * bi-directional many-to-one association to Nation
	 */
	@ManyToOne
	private Nation nation;
	
	@OneToMany(mappedBy="location")
	private List<Excursion> excursions;
	
	@OneToMany(mappedBy="location")
	private List<Hotel> hotels;
	
	@OneToMany(mappedBy="location")
	private List<Airport> airports;
	
	@OneToMany(mappedBy="location")
	private List<Package> packages;
	
	
	//CONSTRUCTORS
	
public Location() {
		
	}
	
	public Location(LocationDTO dto, Nation nation) {
		this.id = dto.getId();
		this.name = dto.getName();
		this.nation = nation;
		this.description = dto.getDescription();
	}
	
	public Location(LocationDTO dto){
		this.id = dto.getId();
		this.name = dto.getName();
		this.description = dto.getDescription();
	}
	
	//GETTER AND SETTER
	
	public List<Airport> getAirports() {
		return airports;
	}

	public void setAirports(List<Airport> airports) {
		this.airports = airports;
	}

	public List<Hotel> getHotels() {
		return hotels;
	}

	public void setHotels(List<Hotel> hotels) {
		this.hotels = hotels;
	}

	public List<Excursion> getExcursions() {
		return excursions;
	}

	public void setExcursions(List<Excursion> excursions) {
		this.excursions = excursions;
	}

	public List<Package> getPackages() {
		return packages;
	}

	public void setPackages(List<Package> packages) {
		this.packages = packages;
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Nation getNation() {
		return this.nation;
	}

	public void setNation(Nation nation) {
		this.nation = nation;
	}

}